package com.ruoyi.tenant.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tenant.domain.SysTenant;
import com.ruoyi.tenant.service.ISysTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


@RestController
@RequestMapping("/system/tenant")
public class tenantMangerController extends BaseController {

    @Autowired
    private ISysTenantService iSysTenantService;


    @GetMapping("/list")
    public TableDataInfo list(SysTenant sysTenant)
    {
        startPage();
        List<SysTenant> list = iSysTenantService.selectSysTenantList(sysTenant);
        return getDataTable(list);
    }




    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        SysTenant SysTenantVo = iSysTenantService.selectSysTenantById(id);
        return success(SysTenantVo);
    }


    @PostMapping
    public AjaxResult add(@RequestBody SysTenant sysTenant)
    {
        return toAjax(iSysTenantService.insertSysTenant(sysTenant).intValue());
    }


    @PutMapping
    public AjaxResult edit(@RequestBody SysTenant sysTenant)
    {
        return toAjax(iSysTenantService.updateSysTenant(sysTenant));
    }


}
